package com.tomecode.mjprocessor.assembly.type;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.apache.maven.model.Profile;

import com.tomecode.mjprocessor.MavenJavaProcessor;
import com.tomecode.mjprocessor.assembly.action.Action;

/**
 * This class contais source and target file and list of actions(replace,insert,
 * etc.) which will be executed
 * 
 * @author Frastia Tomas
 * 
 */
public final class ProjectActions {

	/**
	 * target file - which will be contain values after execute list of actions
	 */
	private File targetFile;
	/**
	 * souce file
	 */
	private File sourceFile;
	/**
	 * process type
	 */
	private final ProcessType type;
	/**
	 * list of actions will be executed
	 */
	private final List<Action> actions;
	/**
	 * if profile is null or empty then this action will be executed everytime
	 * but if profile has value ( for example
	 * {@link MavenJavaProcessor#profiles}
	 */
	private String profile;

	/**
	 * Construktor
	 * 
	 * @param type
	 */
	public ProjectActions(ProcessType type) {
		this.actions = new ArrayList<Action>();
		this.type = type;
	}

	/**
	 * add new {@link Action}
	 * 
	 * @param action
	 */
	public final void addAction(Action action) {
		actions.add(action);
	}

	/**
	 * list of {@link Action}
	 * 
	 * @return
	 */
	public final List<Action> getActions() {
		return actions;
	}

	/**
	 * get {@link #targetFile}
	 * 
	 * @return
	 */
	public final File getTargetFile() {
		return targetFile;
	}

	/**
	 * set new {@link #targetFile}
	 * 
	 * @param targetFile
	 */
	public final void setTargetFile(File targetFile) {
		this.targetFile = targetFile;
	}

	/**
	 * get {@link #sourceFile}
	 * 
	 * @return
	 */
	public final File getSourceFile() {
		return sourceFile;
	}

	/**
	 * set {@link #sourceFile}
	 * 
	 * @param sourceFile
	 */
	public final void setSourceFile(File sourceFile) {
		this.sourceFile = sourceFile;
	}

	/**
	 * get {@link ProcessType}
	 * 
	 * @return
	 */
	public final ProcessType getType() {
		return type;
	}

	/**
	 * set proces {@link Profile}
	 * 
	 * @param profile
	 */
	public final void setProfile(String profile) {
		this.profile = profile;
	}

	/**
	 * return {@link #profile}
	 * 
	 * @return
	 */
	public final String getProfile() {
		return profile;
	}

	/**
	 * if <b>true</b> then profile is this
	 * 
	 * @param profile
	 * @return
	 */
	public final boolean isProfile(String profile) {
		if (this.profile == null || this.profile.trim().length() == 0) {
			return false;
		}
		return this.profile.equals(profile);
	}

}
